import {$message, createHttp} from "../../packages";
import {env} from "../env";

export const http = createHttp({
  baseURL: env.baseURL
});

http.interceptors.response.use(
  resp => {
    if ([404, 500, 403].indexOf(resp.status) > -1) {
      return resp;
    } else {
      const { data } = resp;
      return Object.assign(data, { _resp: resp });
    }
  },
  (error) => {
    $message.error(String(error).toString());
  }
);
